<?php

/**
 * This is the model class for table "v_shoe".
 *
 * The followings are the available columns in table 'v_shoe':
 * @property string $ID
 * @property string $item_title
 * @property string $shoe_suk
 * @property string $item_cover
 * @property string $shoe_content
 * @property string $item_author
 * @property string $item_permissionlv
 * @property string $item_password
 * @property string $item_date
 * @property string $item_modified
 * @property string $item_parent
 */
class Shoe extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'v_shoe';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('shoe_suk', 'unique', 'message'=>'编号重复'),				
			array('item_title, shoe_suk, shoe_content', 'required'),
			array('shoe_suk, item_cover', 'length', 'max'=>200),
			array('item_author, item_permissionlv, item_password, item_parent', 'length', 'max'=>20),
			array('item_date, item_modified', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('ID, item_title, shoe_suk, item_cover, shoe_content, item_author, item_permissionlv, item_password, item_date, item_modified, item_parent', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'ID' => 'ID',
			'item_title' => '页面标题',
			'shoe_suk' => '鞋的编号',
			'item_cover' => '鞋的封面',
			'shoe_content' => '鞋产品大图',
			'item_author' => 'Item Author',
			'item_permissionlv' => '权限级别',
			'item_password' => '访问密码',
			'item_date' => 'Item Date',
			'item_modified' => '最后修改时间',
			'item_parent' => '产品分类',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('ID',$this->ID,true);
		$criteria->compare('item_title',$this->item_title,true);
		$criteria->compare('shoe_suk',$this->shoe_suk,true);
		$criteria->compare('item_cover',$this->item_cover,true);
		$criteria->compare('shoe_content',$this->shoe_content,true);
		$criteria->compare('item_author',$this->item_author,true);
		$criteria->compare('item_permissionlv',$this->item_permissionlv,true);
		$criteria->compare('item_password',$this->item_password,true);
		$criteria->compare('item_date',$this->item_date,true);
		$criteria->compare('item_modified',$this->item_modified,true);
		$criteria->compare('item_parent',$this->item_parent,true);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Shoe the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
